package dd.lo.chapter2;

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.highgui.HighGui;
import org.opencv.videoio.VideoCapture;

public class Example2 {
    public static void main(String[] args) {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        String windowName = "Example2";
        HighGui.namedWindow(windowName, HighGui.WINDOW_AUTOSIZE);
        VideoCapture cap = new VideoCapture("/Users/kwok/Downloads/Raindrops_Videvo.mp4");
        Mat frame = new Mat();
        for (;;) {
            cap.read(frame);
            if (frame.empty()) break; //读取不到帧了，表明到达视频结尾
            HighGui.imshow(windowName, frame);
            if (HighGui.waitKey(10) >= 0) break;
        }
        HighGui.destroyAllWindows();
    }
}
